package com.example.recur;

/**
 * @Date 2023-07-02
 * @Author Jonathan
 */
public class NTree {

    /**
     * 多叉树前序遍历
     */
    public void preOrder(Node node) {
        if (node == null) {
            return;
        }

        System.out.println(node.val);
        for (Node child : node.children) {
            preOrder(child);
        }
    }

    /**
     * 多叉树后序遍历
     */
    public void postOrder(Node node) {
        if (node == null) {
            return;
        }

        for (Node child : node.children) {
            postOrder(child);
        }
        System.out.println(node.val);
    }
}
